package com.hh.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hh.demo.entity.User;
import com.hh.demo.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 吉吉国王
 * @since 2022-07-11
 */
@Service
public class UserService{
    @Resource
    private UserMapper userMapper;
    //录入用户
    public void insertUser(String userName, String sex, Integer age, String grade, String userCard){
        userMapper.insertUser(userName,sex,age,grade,userCard);
    }
    //查询全部用户卡号
    public List<User> queryAllUser(){
        return userMapper.queryAllUser();
    }
    //根据卡号查到借阅人
    public String queryUser(String userCard){
        return userMapper.queryUser(userCard);
    }
    //是否存在该用户
    public boolean isExistUser(String userCard){
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("userCard",userCard);
        return  userMapper.exists(wrapper);
    }
}
